# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Josip Ponjavic <josipponjavic at gmail dot com>
# Contributor: Xu Fasheng <fasheng.xu[AT]gmail.com>

pkgname=dtkwidget
pkgver=5.6.19
pkgrel=1
pkgdesc='Deepin base graphical widgets library'
arch=('loong64' 'x86_64')
url="https://github.com/linuxdeepin/dtkwidget"
license=('LGPL3')
# qt5-imageformats is needed for webp (dci) icons
depends=('dtkcore' 'dtkgui' 'gcc-libs' 'glibc' 'gsettings-qt' 'libx11' 'libxcb' 'libxext' 'libxi'
         'qt5-base' 'qt5-imageformats' 'qt5-svg' 'qt5-x11extras' 'startup-notification' 'xcb-util')
makedepends=('cmake' 'ninja' 'qt5-tools' 'gtest' 'doxygen')
replaces=('deepin-tool-kit')
source=("https://github.com/linuxdeepin/dtkwidget/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha512sums=('3e31c98c1de18e6c7e250caabe5e65ee8d491a8f990067de1990ecaa739d610c47e2266e06b6d27391dfad5e932636ea1af85dd81a723aebeae83bf454a4a3c8')

build() {
  cd dtkwidget-$pkgver
  # Disable plugins because they are not going to be installed
  cmake . -GNinja \
      -DMKSPECS_INSTALL_DIR=lib/qt/mkspecs/modules/ \
      -DBUILD_DOCS=ON \
      -DBUILD_PLUGINS=OFF \
      -DQCH_INSTALL_DESTINATION=share/doc/qt \
      -DCMAKE_INSTALL_LIBDIR=lib \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DDTK_VERSION=$pkgver \
      -DCMAKE_BUILD_TYPE=None
  ninja
}

check() {
  cd dtkwidget-$pkgver
  # TODO
  # ninja test || echo "Tests failed"
}

package() {
  cd dtkwidget-$pkgver
  DESTDIR="$pkgdir" ninja install
}
